package com.xbongbong.saas.enums.dictionary;

import com.xbongbong.i18n.util.I18nMessageUtil;
import com.xbongbong.paas.constant.PaasConstant;
import lombok.Getter;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;

@Getter
public enum ClueStatusEnum {
    // 线索状态状态
    PENDING("1", "enum.clueStatus.name.pending", "pending"),


    FOLLOWING_UP("2", "enum.clueStatus.name.following_up", "followinUp"),


    TRANSFORMED("3", "enum.clueStatus.name.transformed", "transformed"),


    INVALID("4", "enum.clueStatus.name.invalid", "invalid"),

    ;
    private String code;
    private String name;
    private String attr;

    ClueStatusEnum(String code, String name, String attr) {
        this.code = code;
        this.name = name;
        this.attr = attr;
    }

    public static ClueStatusEnum getByCode(String code) {
        for (ClueStatusEnum cache : values()) {
            if (Objects.equals(code, cache.code)) {
                return cache;
            }
        }
        return null;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }

    /**
     * 获取有效线索
     * @return
     */
    public static List<Object> getEffectiveClue() {
        return Arrays.asList(PENDING.getCode(),FOLLOWING_UP.getCode(),TRANSFORMED.getCode());
    }


    public static Map<String, String> getCodeAndNameMap() {
        Map<String, String> map = new HashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
        for (ClueStatusEnum cache : values()) {
            map.put(cache.getCode(), cache.getName());
        }
        return map;
    }

}
